package com.bes.opslink.aiops.system.web.controller.user;

import com.bes.opslink.aiops.commons.dto.base.R;
import com.bes.opslink.aiops.system.api.dto.user.UserDTO;
import com.bes.opslink.aiops.system.entity.user.UserTransfer;
import com.bes.opslink.aiops.system.service.user.IUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
@Tag(name = "用户模块", description = "用户信息相关功能集合")
public class UserController {
    @Autowired
    private IUserService userService;

    /**
     * 根据用户获取用户ID
     *
     * @param id 用户ID
     * @return 用户信息
     */
    @GetMapping("/{id}")
    @Operation(description = "根据用户ID获取用户信息")
    public R<UserDTO> getById(@Parameter(description = "用户ID") @PathVariable("id") Long id) {
        return R.<UserDTO>builder()
                .data(UserTransfer.transfer.toUserDTO(userService.getById(id)))
                .build();
    }

}
